package com.cuiweiyou.happypaint.ui;

import android.graphics.Color;
import android.graphics.Paint;

import java.util.ArrayList;
import java.util.List;

public class ShapeModel {
    private int shapeType = 0; // 直线0，手绘线条1，圆形2，正方形3，三角形4，五角星5。
    private PointModel start_point;
    private PointModel end_point;
    private List<PointModel> pointList = new ArrayList<>();
    private String currentColor;
    private String letter;
    private int currentSize;

    public ShapeModel(String color, int size) {
        this.currentColor = color;
        this.currentSize = size;
    }

    public int getShapeType() {
        return shapeType;
    }

    public void setShapeType(int shapeType) {
        this.shapeType = shapeType;
    }

    public String getLetter() {
        return letter;
    }

    public void setLetter(String letter) {
        this.letter = letter;
    }

    public void setCurrentColor(String currentColor) {
        this.currentColor = currentColor;
    }

    public void setCurrentSize(int currentSize) {
        this.currentSize = currentSize;
    }

    public Paint getPaint() {
        Paint paint = new Paint();
        paint.setColor(Color.parseColor(currentColor)); // 当前颜色
        paint.setStrokeWidth(currentSize); // 当前粗细
        paint.setAntiAlias(true);
        paint.setStrokeCap(Paint.Cap.ROUND);
        paint.setStrokeJoin(Paint.Join.ROUND);
        paint.setStyle(Paint.Style.STROKE);
        return paint;
    }

    public void setStart_point(PointModel start_point) {
        this.start_point = start_point;
    }

    public PointModel getStart_point() {
        return start_point;
    }

    public PointModel getEnd_point() {
        return end_point;
    }

    public void setEnd_point(PointModel end_point) {
        this.end_point = end_point;
    }

    public void addPoint(PointModel point) {
        pointList.add(point);
    }

    public List<PointModel> getPointList() {
        return pointList;
    }

    @Override
    public String toString() {
        return "ShapeModel{" + "shapeType=" + shapeType + ", start_point=" + start_point + ", end_point=" + end_point + ", pointList=" + pointList + ", currentColor='" + currentColor + '\'' + ", letter='" + letter + '\'' + ", currentSize=" + currentSize + '}';
    }

    public static class PointModel {
        private float x;
        private float y;

        public PointModel() {
        }

        public PointModel(float x, float y) {
            this.x = x;
            this.y = y;
        }

        public float getX() {
            return x;
        }

        public void setX(float x) {
            this.x = x;
        }

        public float getY() {
            return y;
        }

        public void setY(float y) {
            this.y = y;
        }

        @Override
        public String toString() {
            return "PointModel{" + "x=" + x + ", y=" + y + '}';
        }
    }
}
